using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Adex{
    /// <summary>
    /// Strongly-typed collection for the VOrder class.
    /// </summary>
    [Serializable]
    public partial class VOrderCollection : ReadOnlyList<VOrder, VOrderCollection>
    {        
        public VOrderCollection() {}

    }

    /// <summary>
    /// This is  Read-only wrapper class for the vOrder view.
    /// </summary>
    [Serializable]
    public partial class VOrder : ReadOnlyRecord<VOrder> 
    {
    
	    #region Default Settings
	    protected static void SetSQLProps() 
	    {
		    GetTableSchema();
	    }

	    #endregion
        #region Schema Accessor
	    public static TableSchema.Table Schema
        {
            get
            {
                if (BaseSchema == null)
                {
                    SetSQLProps();
                }

                return BaseSchema;
            }

        }

    	
        private static void GetTableSchema() 
        {
            if(!IsSchemaInitialized)
            {
                //Schema declaration
                TableSchema.Table schema = new TableSchema.Table("vOrder", TableType.View, DataService.GetInstance("Adex"));
                schema.Columns = new TableSchema.TableColumnCollection();
                schema.SchemaName = "dbo";
                //columns
                
                TableSchema.TableColumn colvarUserName = new TableSchema.TableColumn(schema);
                colvarUserName.ColumnName = "UserName";
                colvarUserName.DataType = DbType.String;
                colvarUserName.MaxLength = 50;
                colvarUserName.AutoIncrement = false;
                colvarUserName.IsNullable = true;
                colvarUserName.IsPrimaryKey = false;
                colvarUserName.IsForeignKey = false;
                colvarUserName.IsReadOnly = false;
                
                schema.Columns.Add(colvarUserName);
                
                TableSchema.TableColumn colvarScreenName = new TableSchema.TableColumn(schema);
                colvarScreenName.ColumnName = "ScreenName";
                colvarScreenName.DataType = DbType.String;
                colvarScreenName.MaxLength = 50;
                colvarScreenName.AutoIncrement = false;
                colvarScreenName.IsNullable = true;
                colvarScreenName.IsPrimaryKey = false;
                colvarScreenName.IsForeignKey = false;
                colvarScreenName.IsReadOnly = false;
                
                schema.Columns.Add(colvarScreenName);
                
                TableSchema.TableColumn colvarEmail = new TableSchema.TableColumn(schema);
                colvarEmail.ColumnName = "Email";
                colvarEmail.DataType = DbType.String;
                colvarEmail.MaxLength = 100;
                colvarEmail.AutoIncrement = false;
                colvarEmail.IsNullable = true;
                colvarEmail.IsPrimaryKey = false;
                colvarEmail.IsForeignKey = false;
                colvarEmail.IsReadOnly = false;
                
                schema.Columns.Add(colvarEmail);
                
                TableSchema.TableColumn colvarCell = new TableSchema.TableColumn(schema);
                colvarCell.ColumnName = "Cell";
                colvarCell.DataType = DbType.String;
                colvarCell.MaxLength = 20;
                colvarCell.AutoIncrement = false;
                colvarCell.IsNullable = true;
                colvarCell.IsPrimaryKey = false;
                colvarCell.IsForeignKey = false;
                colvarCell.IsReadOnly = false;
                
                schema.Columns.Add(colvarCell);
                
                TableSchema.TableColumn colvarFullName = new TableSchema.TableColumn(schema);
                colvarFullName.ColumnName = "FullName";
                colvarFullName.DataType = DbType.String;
                colvarFullName.MaxLength = 100;
                colvarFullName.AutoIncrement = false;
                colvarFullName.IsNullable = true;
                colvarFullName.IsPrimaryKey = false;
                colvarFullName.IsForeignKey = false;
                colvarFullName.IsReadOnly = false;
                
                schema.Columns.Add(colvarFullName);
                
                TableSchema.TableColumn colvarPhoto = new TableSchema.TableColumn(schema);
                colvarPhoto.ColumnName = "Photo";
                colvarPhoto.DataType = DbType.String;
                colvarPhoto.MaxLength = 50;
                colvarPhoto.AutoIncrement = false;
                colvarPhoto.IsNullable = false;
                colvarPhoto.IsPrimaryKey = false;
                colvarPhoto.IsForeignKey = false;
                colvarPhoto.IsReadOnly = false;
                
                schema.Columns.Add(colvarPhoto);
                
                TableSchema.TableColumn colvarActive = new TableSchema.TableColumn(schema);
                colvarActive.ColumnName = "Active";
                colvarActive.DataType = DbType.Boolean;
                colvarActive.MaxLength = 0;
                colvarActive.AutoIncrement = false;
                colvarActive.IsNullable = false;
                colvarActive.IsPrimaryKey = false;
                colvarActive.IsForeignKey = false;
                colvarActive.IsReadOnly = false;
                
                schema.Columns.Add(colvarActive);
                
                TableSchema.TableColumn colvarCompanyName = new TableSchema.TableColumn(schema);
                colvarCompanyName.ColumnName = "CompanyName";
                colvarCompanyName.DataType = DbType.String;
                colvarCompanyName.MaxLength = 255;
                colvarCompanyName.AutoIncrement = false;
                colvarCompanyName.IsNullable = true;
                colvarCompanyName.IsPrimaryKey = false;
                colvarCompanyName.IsForeignKey = false;
                colvarCompanyName.IsReadOnly = false;
                
                schema.Columns.Add(colvarCompanyName);
                
                TableSchema.TableColumn colvarLogo = new TableSchema.TableColumn(schema);
                colvarLogo.ColumnName = "Logo";
                colvarLogo.DataType = DbType.String;
                colvarLogo.MaxLength = 50;
                colvarLogo.AutoIncrement = false;
                colvarLogo.IsNullable = true;
                colvarLogo.IsPrimaryKey = false;
                colvarLogo.IsForeignKey = false;
                colvarLogo.IsReadOnly = false;
                
                schema.Columns.Add(colvarLogo);
                
                TableSchema.TableColumn colvarOrderID = new TableSchema.TableColumn(schema);
                colvarOrderID.ColumnName = "OrderID";
                colvarOrderID.DataType = DbType.Int32;
                colvarOrderID.MaxLength = 0;
                colvarOrderID.AutoIncrement = false;
                colvarOrderID.IsNullable = false;
                colvarOrderID.IsPrimaryKey = false;
                colvarOrderID.IsForeignKey = false;
                colvarOrderID.IsReadOnly = false;
                
                schema.Columns.Add(colvarOrderID);
                
                TableSchema.TableColumn colvarSiteUserID = new TableSchema.TableColumn(schema);
                colvarSiteUserID.ColumnName = "SiteUserID";
                colvarSiteUserID.DataType = DbType.Int32;
                colvarSiteUserID.MaxLength = 0;
                colvarSiteUserID.AutoIncrement = false;
                colvarSiteUserID.IsNullable = true;
                colvarSiteUserID.IsPrimaryKey = false;
                colvarSiteUserID.IsForeignKey = false;
                colvarSiteUserID.IsReadOnly = false;
                
                schema.Columns.Add(colvarSiteUserID);
                
                TableSchema.TableColumn colvarCompanyCode = new TableSchema.TableColumn(schema);
                colvarCompanyCode.ColumnName = "CompanyCode";
                colvarCompanyCode.DataType = DbType.Int32;
                colvarCompanyCode.MaxLength = 0;
                colvarCompanyCode.AutoIncrement = false;
                colvarCompanyCode.IsNullable = true;
                colvarCompanyCode.IsPrimaryKey = false;
                colvarCompanyCode.IsForeignKey = false;
                colvarCompanyCode.IsReadOnly = false;
                
                schema.Columns.Add(colvarCompanyCode);
                
                TableSchema.TableColumn colvarOrderStatus = new TableSchema.TableColumn(schema);
                colvarOrderStatus.ColumnName = "OrderStatus";
                colvarOrderStatus.DataType = DbType.Byte;
                colvarOrderStatus.MaxLength = 0;
                colvarOrderStatus.AutoIncrement = false;
                colvarOrderStatus.IsNullable = true;
                colvarOrderStatus.IsPrimaryKey = false;
                colvarOrderStatus.IsForeignKey = false;
                colvarOrderStatus.IsReadOnly = false;
                
                schema.Columns.Add(colvarOrderStatus);
                
                TableSchema.TableColumn colvarOrderTotal = new TableSchema.TableColumn(schema);
                colvarOrderTotal.ColumnName = "OrderTotal";
                colvarOrderTotal.DataType = DbType.Currency;
                colvarOrderTotal.MaxLength = 0;
                colvarOrderTotal.AutoIncrement = false;
                colvarOrderTotal.IsNullable = false;
                colvarOrderTotal.IsPrimaryKey = false;
                colvarOrderTotal.IsForeignKey = false;
                colvarOrderTotal.IsReadOnly = false;
                
                schema.Columns.Add(colvarOrderTotal);
                
                TableSchema.TableColumn colvarCompanyUnlimitedCredits = new TableSchema.TableColumn(schema);
                colvarCompanyUnlimitedCredits.ColumnName = "CompanyUnlimitedCredits";
                colvarCompanyUnlimitedCredits.DataType = DbType.Boolean;
                colvarCompanyUnlimitedCredits.MaxLength = 0;
                colvarCompanyUnlimitedCredits.AutoIncrement = false;
                colvarCompanyUnlimitedCredits.IsNullable = false;
                colvarCompanyUnlimitedCredits.IsPrimaryKey = false;
                colvarCompanyUnlimitedCredits.IsForeignKey = false;
                colvarCompanyUnlimitedCredits.IsReadOnly = false;
                
                schema.Columns.Add(colvarCompanyUnlimitedCredits);
                
                TableSchema.TableColumn colvarPricePerSecondOnOrder = new TableSchema.TableColumn(schema);
                colvarPricePerSecondOnOrder.ColumnName = "PricePerSecondOnOrder";
                colvarPricePerSecondOnOrder.DataType = DbType.Currency;
                colvarPricePerSecondOnOrder.MaxLength = 0;
                colvarPricePerSecondOnOrder.AutoIncrement = false;
                colvarPricePerSecondOnOrder.IsNullable = true;
                colvarPricePerSecondOnOrder.IsPrimaryKey = false;
                colvarPricePerSecondOnOrder.IsForeignKey = false;
                colvarPricePerSecondOnOrder.IsReadOnly = false;
                
                schema.Columns.Add(colvarPricePerSecondOnOrder);
                
                TableSchema.TableColumn colvarDateAdded = new TableSchema.TableColumn(schema);
                colvarDateAdded.ColumnName = "DateAdded";
                colvarDateAdded.DataType = DbType.DateTime;
                colvarDateAdded.MaxLength = 0;
                colvarDateAdded.AutoIncrement = false;
                colvarDateAdded.IsNullable = false;
                colvarDateAdded.IsPrimaryKey = false;
                colvarDateAdded.IsForeignKey = false;
                colvarDateAdded.IsReadOnly = false;
                
                schema.Columns.Add(colvarDateAdded);
                
                TableSchema.TableColumn colvarDateModified = new TableSchema.TableColumn(schema);
                colvarDateModified.ColumnName = "DateModified";
                colvarDateModified.DataType = DbType.DateTime;
                colvarDateModified.MaxLength = 0;
                colvarDateModified.AutoIncrement = false;
                colvarDateModified.IsNullable = false;
                colvarDateModified.IsPrimaryKey = false;
                colvarDateModified.IsForeignKey = false;
                colvarDateModified.IsReadOnly = false;
                
                schema.Columns.Add(colvarDateModified);
                
                TableSchema.TableColumn colvarCountryID = new TableSchema.TableColumn(schema);
                colvarCountryID.ColumnName = "CountryID";
                colvarCountryID.DataType = DbType.Byte;
                colvarCountryID.MaxLength = 0;
                colvarCountryID.AutoIncrement = false;
                colvarCountryID.IsNullable = true;
                colvarCountryID.IsPrimaryKey = false;
                colvarCountryID.IsForeignKey = false;
                colvarCountryID.IsReadOnly = false;
                
                schema.Columns.Add(colvarCountryID);
                
                
                BaseSchema = schema;
                //add this schema to the provider
                //so we can query it later
                DataService.Providers["Adex"].AddSchema("vOrder",schema);
            }

        }

        #endregion
        
        #region Query Accessor
	    public static Query CreateQuery()
	    {
		    return new Query(Schema);
	    }

	    #endregion
	    
	    #region .ctors
	    public VOrder()
	    {
            SetSQLProps();
            SetDefaults();
            MarkNew();
        }

        public VOrder(bool useDatabaseDefaults)
	    {
		    SetSQLProps();
		    if(useDatabaseDefaults)
		    {
				ForceDefaults();
			}

			MarkNew();
	    }

	    
	    public VOrder(object keyID)
	    {
		    SetSQLProps();
		    LoadByKey(keyID);
	    }

    	 
	    public VOrder(string columnName, object columnValue)
        {
            SetSQLProps();
            LoadByParam(columnName,columnValue);
        }

        
	    #endregion
	    
	    #region Props
	    
          
        [XmlAttribute("UserName")]
        public string UserName 
	    {
		    get
		    {
			    return GetColumnValue<string>("UserName");
		    }

            set 
		    {
			    SetColumnValue("UserName", value);
            }

        }

	      
        [XmlAttribute("ScreenName")]
        public string ScreenName 
	    {
		    get
		    {
			    return GetColumnValue<string>("ScreenName");
		    }

            set 
		    {
			    SetColumnValue("ScreenName", value);
            }

        }

	      
        [XmlAttribute("Email")]
        public string Email 
	    {
		    get
		    {
			    return GetColumnValue<string>("Email");
		    }

            set 
		    {
			    SetColumnValue("Email", value);
            }

        }

	      
        [XmlAttribute("Cell")]
        public string Cell 
	    {
		    get
		    {
			    return GetColumnValue<string>("Cell");
		    }

            set 
		    {
			    SetColumnValue("Cell", value);
            }

        }

	      
        [XmlAttribute("FullName")]
        public string FullName 
	    {
		    get
		    {
			    return GetColumnValue<string>("FullName");
		    }

            set 
		    {
			    SetColumnValue("FullName", value);
            }

        }

	      
        [XmlAttribute("Photo")]
        public string Photo 
	    {
		    get
		    {
			    return GetColumnValue<string>("Photo");
		    }

            set 
		    {
			    SetColumnValue("Photo", value);
            }

        }

	      
        [XmlAttribute("Active")]
        public bool Active 
	    {
		    get
		    {
			    return GetColumnValue<bool>("Active");
		    }

            set 
		    {
			    SetColumnValue("Active", value);
            }

        }

	      
        [XmlAttribute("CompanyName")]
        public string CompanyName 
	    {
		    get
		    {
			    return GetColumnValue<string>("CompanyName");
		    }

            set 
		    {
			    SetColumnValue("CompanyName", value);
            }

        }

	      
        [XmlAttribute("Logo")]
        public string Logo 
	    {
		    get
		    {
			    return GetColumnValue<string>("Logo");
		    }

            set 
		    {
			    SetColumnValue("Logo", value);
            }

        }

	      
        [XmlAttribute("OrderID")]
        public int OrderID 
	    {
		    get
		    {
			    return GetColumnValue<int>("OrderID");
		    }

            set 
		    {
			    SetColumnValue("OrderID", value);
            }

        }

	      
        [XmlAttribute("SiteUserID")]
        public int? SiteUserID 
	    {
		    get
		    {
			    return GetColumnValue<int?>("SiteUserID");
		    }

            set 
		    {
			    SetColumnValue("SiteUserID", value);
            }

        }

	      
        [XmlAttribute("CompanyCode")]
        public int? CompanyCode 
	    {
		    get
		    {
			    return GetColumnValue<int?>("CompanyCode");
		    }

            set 
		    {
			    SetColumnValue("CompanyCode", value);
            }

        }

	      
        [XmlAttribute("OrderStatus")]
        public byte? OrderStatus 
	    {
		    get
		    {
			    return GetColumnValue<byte?>("OrderStatus");
		    }

            set 
		    {
			    SetColumnValue("OrderStatus", value);
            }

        }

	      
        [XmlAttribute("OrderTotal")]
        public decimal OrderTotal 
	    {
		    get
		    {
			    return GetColumnValue<decimal>("OrderTotal");
		    }

            set 
		    {
			    SetColumnValue("OrderTotal", value);
            }

        }

	      
        [XmlAttribute("CompanyUnlimitedCredits")]
        public bool CompanyUnlimitedCredits 
	    {
		    get
		    {
			    return GetColumnValue<bool>("CompanyUnlimitedCredits");
		    }

            set 
		    {
			    SetColumnValue("CompanyUnlimitedCredits", value);
            }

        }

	      
        [XmlAttribute("PricePerSecondOnOrder")]
        public decimal? PricePerSecondOnOrder 
	    {
		    get
		    {
			    return GetColumnValue<decimal?>("PricePerSecondOnOrder");
		    }

            set 
		    {
			    SetColumnValue("PricePerSecondOnOrder", value);
            }

        }

	      
        [XmlAttribute("DateAdded")]
        public DateTime DateAdded 
	    {
		    get
		    {
			    return GetColumnValue<DateTime>("DateAdded");
		    }

            set 
		    {
			    SetColumnValue("DateAdded", value);
            }

        }

	      
        [XmlAttribute("DateModified")]
        public DateTime DateModified 
	    {
		    get
		    {
			    return GetColumnValue<DateTime>("DateModified");
		    }

            set 
		    {
			    SetColumnValue("DateModified", value);
            }

        }

	      
        [XmlAttribute("CountryID")]
        public byte? CountryID 
	    {
		    get
		    {
			    return GetColumnValue<byte?>("CountryID");
		    }

            set 
		    {
			    SetColumnValue("CountryID", value);
            }

        }

	    
	    #endregion
    
	    #region Columns Struct
	    public struct Columns
	    {
		    
		    
            public static string UserName = @"UserName";
            
            public static string ScreenName = @"ScreenName";
            
            public static string Email = @"Email";
            
            public static string Cell = @"Cell";
            
            public static string FullName = @"FullName";
            
            public static string Photo = @"Photo";
            
            public static string Active = @"Active";
            
            public static string CompanyName = @"CompanyName";
            
            public static string Logo = @"Logo";
            
            public static string OrderID = @"OrderID";
            
            public static string SiteUserID = @"SiteUserID";
            
            public static string CompanyCode = @"CompanyCode";
            
            public static string OrderStatus = @"OrderStatus";
            
            public static string OrderTotal = @"OrderTotal";
            
            public static string CompanyUnlimitedCredits = @"CompanyUnlimitedCredits";
            
            public static string PricePerSecondOnOrder = @"PricePerSecondOnOrder";
            
            public static string DateAdded = @"DateAdded";
            
            public static string DateModified = @"DateModified";
            
            public static string CountryID = @"CountryID";
            
	    }

	    #endregion
    }

}

